package org.stream;

import org.entity.Employee;
import org.junit.jupiter.api.Test;

import java.util.DoubleSummaryStatistics;
import java.util.IntSummaryStatistics;
import java.util.stream.Collectors;

/**
 * @Description
 * @Author wjj
 * @Date 2023/4/17 23:19
 */
public class Statistics {

    @Test
    public void statisticsTest(){
        DoubleSummaryStatistics incomeStats = Employee.persons()
                .stream()
                .map(Employee::getIncome)
                .collect(DoubleSummaryStatistics::new,
                        DoubleSummaryStatistics::accept,
                        DoubleSummaryStatistics::combine);
        System.out.println(incomeStats);
    }

    @Test
    public void statisticsTest2(){
        DoubleSummaryStatistics incomeStats = Employee.persons()
                .stream()
                .collect(Collectors.summarizingDouble(Employee::getIncome));
        System.out.println(incomeStats);
    }
}
